<include file="Public/header" />
<title>我的桌面</title>
</head>
<body>
<div class="page-container">
    <div class="text-c"> 日期范围：
        <input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}'})" id="logmin" name="start_time" value="<{$Think.get.start_time}>" class="input-text Wdate" style="width:120px;">
        -
        <input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d'})" id="logmax" name="end_time" value="<{$Think.get.end_time}>" class="input-text Wdate" style="width:120px;">
        <input type="text" name="goods_no"  value="<{$Think.get.goods_no}>" placeholder="商品编码" style="width:250px" class="input-text">
		<input type="text" name="goods_name"  value="<{$Think.get.goods_name}>" placeholder="商品名称" style="width:250px" class="input-text">
		<input type="text" name="warehouse_code"  value="<{$Think.get.warehouse_code}>" placeholder="仓库编码" style="width:250px" class="input-text">
        <button id="search" class="btn btn-success" type="submit"><i class="Hui-iconfont"></i> 搜索</button>
    </div>
    <div class="mt-20">
        <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
            <div class="dataTables_length" id="DataTables_Table_0_length"><label>
                显示 <select tabindex="<{$Think.get.page_count}>" name="page_count" aria-controls="DataTables_Table_0" class="select">
                <option value="15">15</option><option value="25">25</option><option value="50">50</option>
                <option value="100">100</option></select> 条</label>
                <span class="r" style="margin-left:60px;">共有数据：<strong><{$count}></strong> 条</span>
            </div>
            <table class="table table-border table-bordered table-bg table-hover table-sort dataTable no-footer" id="DataTables_Table_0" role="grid" aria-describedby="DataTables_Table_0_info">
                <thead>
                <tr class="text-c" role="row">
                    <th width="25" class="sorting_disabled" rowspan="1" colspan="1" aria-label="" style="width: 25px;"><input type="checkbox" name="" value=""></th>
                    <th width="80" class="sorting_desc" tabindex="id" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">ID</th>
					<th width="60">货号</th>
					<th width="60">商品编码</th>
                    <th width="140">产品名称</th>
                    <th class="sorting" tabindex="warehouse_name" width="60">仓库名称</th>
                    <th class="sorting" tabindex="warehouse_code" width="60">仓库编码</th>
                    <th width="65">价格</th>
                    <th class="sorting" tabindex="unit_no" width="60">主单位名称</th>
                    <th width="60">库存数量</th>
					<th width="60">可售库存数量</th>
					<th width="60">是否云仓商品</th>
					<th width="60">云仓商品数量</th>
					<th width="60">云仓商品单位</th>
                    <th class="sorting" tabindex="is_shelves" width="80">是否上架</th>
                    <th width="120">添加时间</th>
                    <th width="90">操作</th>
                </tr>
                </thead>
                <tbody>
                <foreach name="list" item="data">
                    <tr class="text-c odd" role="row">
                        <td><eq name="data.is_shelves" value="1"><input type="checkbox" value="<{$data.id}>" name=""></eq></td>
                        <td class="sorting_1"><{$data.id}></td>
						<td class="text-l"><{$data.goods_sn}></td>
						<td class="text-l"><{$data.goods_no}></td>
                        <td class="text-l"><{$data.goods_name}></td>
                        <td><{$data.warehouse_name}></td>
                        <td><{$data.warehouse_code}></td>
                        <td><{$data.price}></td>
                        <td class="td-status"><{$data.unit_name}></td>
                        <td><{$data.storage_amount}></td>
						<td><{$data['storage_amount']-$data['nonconforming_p']-$data['scrap_one']-$data['scrap_two']}></td>
						<td>
						<eq name="data.cloud_depot_status" value="0">否</eq>
						<eq name="data.cloud_depot_status" value="1">是</eq>
						</td>
						<td><{$data.cloud_num}></td>
						<td><{$data.cloud_unit_name}></td>
                        <td class="td-status">
                            <eq name="data.grounding_status" value="1">已上架<else/>未上架</eq>
                        </td>
                        <td><{$data.add_time|date="Y:m:d H:i:s",###}></td>
                        <td>
							<if condition="$data.grounding_status neq 1">
								<a style="text-decoration:none" class="ml-5 label label-success radius" onclick="edit('<{$data.id}>')" href="javascript:;">上架</a>
							<else />
								<a style="text-decoration:none" class="ml-5 label label-danger radius" onclick="grounding('2','<{$data.id}>')" href="javascript:;">下架</a>
							</if>
                        </td>
                    </tr>
                </foreach>
                </tbody>
            </table>
            <div style="margin-top: 12px;" class="Huialert Huialert-info"><i class="icon-remove"></i>上架后此商品库存数量才可计入待销售的总库存信息</div>
            <div style="margin-top: 32px;">
                <!-- <a href="javascript:;" tabindex="<{$list_id}>" onclick="delAll()" class="btn btn-danger radius"><i class="Hui-iconfont"></i> 批量删除</a> -->
            </div>
            <div style="margin-top: 12px;" class="page"><{$page}></div>
        </div>
    </div>
    <include file="Public/footer" />
    <include file="Public/footer_js" />
    <script>
        function delAll(){
            var all_ipt=$("#DataTables_Table_0_wrapper input[type=checkbox]:checked");
            var group_id='';
            for(var i=0;i<all_ipt.length;i++){
                if(all_ipt.eq(i).val()!==''){
                    group_id+='@'+all_ipt.eq(i).val();
                }
            }
            if(group_id.substring(1)==''){
                layer.msg('请勾选要删除的信息');
                return false;
            }
            del(group_id.substring(1));
        }
        function del(id){
            $.get('__MODULE__/Goods/del',{
                id:id,
            },function (msg){
                layer.msg(msg.data);
                if(msg.flag==1){
                    setTimeout(function (){
                        location.reload();
                    },800);
                }
            },'json');
        }
        function detailBack(id){
            if(isNaN(id)){
                layer.msg('操作有误');
                return false;
            }
            layer.prompt({title: '请输入该商品的实际件数', formType: 0}, function(text, index){
                if(isNaN(text)){
                    layer.msg('操作有误');
                    return false;
                }
                $.post('__MODULE__/Goods/detailBack',{
                    id:id,
                    count:text,
                },function (msg){
                    layer.msg(msg.data);
                    if(msg.flag==1){
                        setTimeout(function (){
                            location.reload();
                        },800);
                    }
                },'json');
            });
        }
        function lastSure(id){
            layer.confirm('您确定要确认嘛？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                $.post('__MODULE__/Goods/lastSure',{
                    id:id,
                },function (msg){
                    layer.msg(msg.data);
                    if(msg.flag==1){
                        setTimeout(function (){
                            location.reload();
                        },800);
                    }
                },'json');
            });
        }
		//上架
		function edit(id){
			var index=layer.open({
				type: 2,
				title: '修改并上架',
				shadeClose: true,
				shade: 0.5,
				offset:['180px'],
				area: ['320px', '335px'],
				content: '__MODULE__/Goods/edit/id/'+id+"/"+Math.random() //iframe的url
			});
		}
		//下架
        function grounding(type,id){
            if(isNaN(id)){
                layer.msg('操作有误');
                return false;
            }
            $.post('__MODULE__/Goods/grounding',{
                id:id,
                type:type,
            },function (msg){
                layer.msg(msg.data);
                if(msg.flag==1){
                    setTimeout(function (){
                        location.reload();
                    },800);
                }
            },'json');
        }
        $("select[name=page_count]").on('change',function (){
            search();
        });
        $("#search").on('click',function (){
            search();
        });
        function search(_this){
            var page_count=$("select[name=page_count]").val();
            var start_time=$("input[name=start_time]").val();
            var end_time=$("input[name=end_time]").val();
            var goods_name=$("input[name=goods_name]").val();
			var goods_no=$("input[name=goods_no]").val();
            var category=$("select[name=category]").val();
            var sort,dec;
            if(_this){
                if(_this.attr('class')=='sorting_desc'){
                    sort=_this.attr('tabindex');
                    dec='asc';
                }
                if(_this.attr('class')=='sorting_asc'){
                    sort=_this.attr('tabindex');
                    dec='desc';
                }
                if(_this.attr('class')=='sorting'){
                    sort=_this.attr('tabindex');
                    dec='asc';
                }
            }else{
                sort='';
                dec='';
            }
            location.href="__ACTION__?goods_name="+goods_name+"&goods_no="+goods_no+"&page_count="+page_count+"&start_time="+start_time+"&end_time="+end_time+"&sort="+sort+"&dec="+dec;
        }

        (function(){
            if($("select[name=page_count]").attr('tabindex')==''){
                var  page=15;
            }else{
                var  page=$("select[name=page_count]").attr('tabindex');
            }
            $("select[name=page_count]").prop('value',page);
            $(".sorting,.sorting_desc,.sorting_asc").click(function (){
                search($(this));
            });
            for(var i=0;i<$(".sorting,.sorting_desc,.sorting_asc").length;i++){
                if('<{$Think.get.sort}>'!=''){
                    if($(".sorting,.sorting_desc,.sorting_asc").eq(i).attr('tabindex')=='<{$Think.get.sort}>'){
                        $(".sorting,.sorting_desc,.sorting_asc").attr('class','sorting');
                        $(".sorting,.sorting_desc,.sorting_asc").eq(i).attr('class','sorting_<{$Think.get.dec}>');
                    }
                }
            }
        })();
    </script>
</body>
</html>